package cn.sh.ideal.productservice.controller;

import cn.sh.ideal.productservice.service.ProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author mr_zhao
 */
@RestController
@RequestMapping("/api/vi/product")
public class ProductController {

    private static Logger logger= LoggerFactory.getLogger(ProductController.class);

    @Resource
    private ProductService productService;

    /**
     * @Description: 获取所有商品列表
     * @Param: []
     * @return: java.lang.String
     * @Author: mr_zhao
     * @Date: 2020/7/4-14:21
     */
    @RequestMapping(value = "listProduct")
    public Object ListProduct() {

        return productService.listProduct();

    }


    /**
     * @Description: 根据Id获取商品
     * @Param: []
     * @return: java.lang.String
     * @Author: mr_zhao
     * @Date: 2020/7/4-14:21
     */
    @RequestMapping(value = "findProductById")
    public Object findProductById(@RequestParam(value = "productId") Integer id) {
        logger.info("Service Product findProductById");
        return productService.findProductById(id);
    }

}